package com.asen.commons.core.jdbc.builder.mysql.filter;

import com.asen.commons.core.jdbc.param.SqlColumn;
import com.asen.commons.core.jdbc.param.SqlContextManager;
import com.asen.commons.core.meta.dao.FilterItem;

/**
 * 空值比较过滤解析器
 *
 * @author Gary
 * @version 1.0
 * @date 2021-08-22
 */
public class NullFilterParser implements FilterParser {

    @Override
    public CharSequence parse(SqlContextManager contextManager, FilterItem filterItem) {
        SqlColumn sqlColumn = contextManager.getSqlColumn(filterItem.getFieldName());
        if (sqlColumn == null) {
            return "";
        }

        StringBuilder sql = new StringBuilder(sqlColumn.getFullColumn())
                .append(filterItem.getSymbol().getDesc());
        return sql;
    }

}
